<template>
  <div class="statisticalanalysis">
    <el-button @click="print" class="signs print" v-if="list.shStatus==2">打印</el-button>  
    <el-tooltip class="item" effect="dark" content="审核通过才可以打印" v-else placement="top-start">
      <el-button class="signs print" style="cursor:not-allowed;">打印</el-button>  
    </el-tooltip>
    <div ref="print">
      <el-card class="box-card" >
          <div style="width:100%;text-align:center;">
              <span style="height:45px;display:inline-block;line-height:45px;font-weight:700;">高处安全作业证</span>
          </div>
          <table  border="1" cellspacing="0">
          <tr align="center" height="35px">
            <td width="16%">申请单位</td>
            <td width="16%">{{list.sqdwmc}}</td>
            <td>申请人</td>
            <td width="16%">{{list.sqrmc}}</td>
            <td width="16%">作业证编号</td>
            <td width="16%" colspan="2">{{list.zyzbh}}</td>
          </tr>
          <tr align="center" height="35px">
            <td colspan="1">作业时间</td>
            <td colspan="10" align="center" style="padding-right:4rem;">
              自<span>{{list.zykssj}}</span>
              始<span>{{list.zyjssj}}</span>止
            </td>
          </tr>
          <tr align="center" height="35px">
            <td colspan="1">作业地点</td>
            <td colspan="5">{{list.zydd}}</td>
          </tr>
          <tr align="center" height="35px">
            <td colspan="1">作业内容</td>
            <td colspan="5">{{list.zynr}}</td>
          </tr> 
          <tr align="center" height="35px">
            <td>作业高度</td>
            <td>{{list.zygd}}</td>
            <td colspan="2">作业类别</td>
            <td colspan="2">{{list.zylb}}</td>
          </tr>
          <tr align="center" height="35px">
            <td>作业单位</td>
            <td>{{list.zydwmc}}</td>
            <td colspan="2">监督人</td>
            <td colspan="2">{{list.jdrmc}}</td>
          </tr>
          <tr align="center" height="80px">
            <td colspan="1">危害辨识</td>
            <td colspan="5">{{list.whbs}}</td>
          </tr>
          <!-- 安全措施 -->
          <tr align="center" height="35px">
            <td>序号</td>
            <td colspan="4">安全措施</td>
            <td >确认人</td>
          </tr>
          <tr align="center" height="40px">
            <td>1</td>
            <td class="textleft" colspan="4">作业人员身体条件符合要求</td>
            <td>{{list.aqcsqrrmc}}</td>
          </tr>
          <tr align="center" height="40px">
            <td>2</td>
            <td class="textleft" colspan="4">作业人员着装符合工作要求</td>
            <td>{{list.aqcsqrrmc}}</td>
          </tr>
          <tr align="center" height="40px">
            <td>3</td>
            <td class="textleft" colspan="4">作业人员佩戴合格的安全帽</td>
            <td>{{list.aqcsqrrmc}}</td>
          </tr>
          <tr align="center" height="40px">
            <td>4</td>
            <td class="textleft" colspan="4">作业人员佩戴安全带，安全带要高挂低用 </td>
            <td>{{list.aqcsqrrmc}}</td>
          </tr>
          <tr align="center" height="40px">
            <td>5</td>
            <td class="textleft" colspan="4">作业人员携带有工具袋及安全绳
            </td>
            <td>{{list.aqcsqrrmc}}</td>
          </tr>
          <tr align="center" height="40px">
            <td>6</td>
            <td class="textleft" colspan="4">作业人员佩戴：A.过滤式防毒面具或口罩 B.空气呼吸器/已采用）防爆工具</td>
            <td>{{list.aqcsqrrmc}}</td>
          </tr>
          <tr align="center" height="40px">
            <td>7</td>
            <td class="textleft" colspan="4">现场搭设的脚手架、防护网、围栏符合安全规定</td>
            <td>{{list.aqcsqrrmc}}</td>
          </tr>
          <tr align="center" height="40px">
            <td>8</td>
            <td class="textleft" colspan="4">垂直分层作业中间有隔离设施</td>
            <td>{{list.aqcsqrrmc}}</td>
          </tr>
          <tr align="center" height="40px">
            <td>9</td>
            <td class="textleft" colspan="4">梯子、绳子符合安全规定</td>
            <td>{{list.aqcsqrrmc}}</td>
          </tr>
          <tr align="center" height="40px">
            <td>10</td>
            <td class="textleft" colspan="4">石棉瓦等轻型棚的承重梁、柱能承重负荷的要求</td>
            <td>{{list.aqcsqrrmc}}</td>
          </tr>
          <tr align="center" height="40px">
            <td>11</td>
            <td class="textleft" colspan="4">作业人员在石棉瓦等不承重物作业所搭设的承重板稳定牢固</td>
            <td>{{list.aqcsqrrmc}}</td>
          </tr>
          <tr align="center" height="40px">
            <td>12</td>
            <td class="textleft" colspan="4">采光，夜间作业照明符合作业要求，（需采用并已采用/无需采用）防爆灯</td>
            <td>{{list.aqcsqrrmc}}</td>
          </tr>
          <tr align="center" height="40px">
            <td>13</td>
            <td class="textleft" colspan="4">30m以上高处作业配备通讯、联络工具</td>
            <td>{{list.aqcsqrrmc}}</td>
          </tr>
          <tr align="center" height="80px">
            <td>14</td>
              <td colspan="4">
              <div class="tdPostion">
                <p class="Safetymeasures">其他安全措施：{{list.qtaqcs}}</p>
              </div>
              <div class="trPositon">
                <p class="makePeopleTwo">编制人：{{list.qtaqcsbzrmc}}</p>
              </div>
            </td>
            <td>{{list.qtaqcsqrrmc}}</td>
          </tr>
          <tr align="center" height="40px">
            <td>实施安全教育</td>
            <td>{{list.ssaqjyrmc}}</td>
            <td colspan="2"></td>
            <td colspan="2"></td>
          </tr>
          <tr height="60px">
            <td colspan="6" style="border-bottom:none;padding-left:10px;">
              生产单位作业负责人意见：{{list.scdwzyfzryj}}
            </td>
          </tr>
          <tr height="60px">
            <td align="right" colspan="6" style="border-top:none;padding-right:2rem;">
              签字：{{list.scdwzyfzrqmmc}}
              <span style="padding-left:1rem;">{{list.scdwzyfzrqmsj}}</span>
            </td>
          </tr>
          <tr height="60px">
            <td colspan="6" style="border-bottom:none;padding-left:10px;">
              作业单位负责人意见：{{list.zydwfzryj}}
            </td>
          </tr>
          <tr height="60px">
            <td align="right" colspan="6" style="border-top:none;padding-right:2rem;">
              <span>签字：{{list.zydwfzrqmmc}}</span>
              <span style="padding-left:1rem;">{{list.zydwfzrqmsj}}</span>
            </td>
          </tr>
          <tr height="60px">
            <td colspan="6" style="border-bottom:none;padding-left:10px;">
              审核部门意见：{{list.shbmyj}}
            </td>
          </tr>
          <tr height="60px">
            <td align="right" colspan="6" style="border-top:none;padding-right:2rem;">
              签字：{{list.shbmqmmc}}
              <span style="padding-left:1rem;">{{list.shsj}}</span>
            </td>
          </tr>
          <tr height="60px">
            <td colspan="6" style="border-bottom:none;padding-left:10px;">
              审批部门意见：{{list.spbmyj}}
            </td>
          </tr>
          <tr height="60px">
            <td align="right" colspan="6" style="border-top:none;padding-right:2rem;">
              签字：{{list.spbmqmmc}}
              <span style="padding-left:1rem;">{{list.spsj}}</span>
            </td>
          </tr>
          <tr height="60px">
            <td colspan="6" style="border-bottom:none;padding-left:10px;">
              完工验收：{{list.wgysyj}}
            </td>
          </tr>
          <tr height="60px">
            <td align="right" colspan="6" style="border-top:none;padding-right:2rem;">
              签字：{{list.wgysqmmc}}
              <span style="padding-left:1rem;">{{list.wgyssj}}</span>
            </td>
          </tr>
        </table>
      </el-card>
    </div>
  </div>
</template>

<script>
import printStyle from './printStyle'

export default {
  props: {
    list: {
      type:Object,
      default:{}
    }
  },
  name:'gaochu',
  data() {
    return {
    }
  },
  created() {
    this.list.scdwzyfzrqmsj = this.formatDateH(this.list.scdwzyfzrqmsj);
    this.list.shsj = this.formatDateH(this.list.shsj);
    this.list.spsj = this.formatDateH(this.list.spsj);
    this.list.zydwfzrqmsj = this.formatDateH(this.list.zydwfzrqmsj);
    this.list.zyjssj = this.formatDateH(this.list.zyjssj);
    this.list.zykssj = this.formatDateH(this.list.zykssj);
    this.list.wgyssj = this.formatDateH(this.list.wgyssj);
  },
  methods:{
    formatDate(needTime){
      //needTime是整数，否则要parseInt转换
        if(needTime !== null && needTime !== undefined){
          var time = new Date(needTime);
          var y = time.getFullYear();
          var m = time.getMonth()+1;
          var d = time.getDate();
          var h = time.getHours();
          var mm = time.getMinutes();
          return y+'年'+this.add0(m)+'月'+this.add0(d)+'日';
        }else{
          return '  年  月  日 ';
        }
    },
    formatDateH(needTime){
      //needTime是整数，否则要parseInt转换
        if(needTime !== null && needTime !== undefined){
          var time = new Date(needTime);
          var y = time.getFullYear();
          var m = time.getMonth()+1;
          var d = time.getDate();
          var h = time.getHours();
          var mm = time.getMinutes();
          // var s = time.getSeconds();
          return y+'年'+this.add0(m)+'月'+this.add0(d)+'日'+this.add0(h)+'时'+this.add0(mm)+'分';
        }else{
          return '  年  月  日  时  分';
        }
    },
    add0(m){
      return m<10 ?'0'+m :m 
    },
    // 打印
    print() {
      let print = this.$refs.print.innerHTML
      let printPart = print + printStyle;
      let newTab = window.open('_blank');
      newTab.document.body.innerHTML = printPart;
      newTab.print();
      newTab.close();
    },
  },
}
</script>

<style lang="scss" scoped>
.statisticalanalysis {
  .signs {
        position: absolute;
        right: 10px;
        top: 70px;
        &.print {
            top: 20px;
            right:50px;
        }
   }
  .box-card { 
    width: 80%;
    margin: 0 auto;
    background: #fff;
    color: #606266;
    position: relative;
    table {
      margin: 0 auto;
      tr {
        .textleft {
          text-align:left;
          padding-left: 20px;
        }
      }
      span {
          display:inline-block;
          min-width:20px;
      }
      // 其他安全措施
      tr:nth-child(22) {
        .trPositon {
          position: relative;
          height:90px;
          width: 100%;
          .makePeopleTwo {
            position: absolute;
            right: 15%;
            top: 60%;
          }
        }
        .tdPostion {
          position: relative;
          width: 100%;
          height: 30px;
          .Safetymeasures {
            position: absolute;
            left: 2%;
            top: 50%;
          }
        }
      }
    }
  }
}
</style>